/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.com.transportes.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import pe.com.transportes.modelo.Bus;
import pe.com.transportes.modelo.Chofer;

/**
 *
 * @author PFR
 */
public class ChoferDAO {


      public void insertarchofer(Connection con,Chofer c) throws SQLException{

    String sql ="insert into chofer values (?,?,?,?,?,?,?,?)";
    PreparedStatement ps = con.prepareStatement(sql);


    System.out.println("codigo dao "+c.getCod_chofer());

    ps.setInt(1,c.getCod_chofer());
          ps.setInt(2,c.getCod_ruta());
          ps.setString(3, c.getNom_chofer());
        ps.setString(4,c.getApe_chofer());
        ps.setInt(5,c.getTelefono());
          ps.setDouble(6, c.getSueldo());
        ps.setString(7, c.getFnacimiento());
        ps.setString(8, c.getTurno());


    ps.executeUpdate();
    }

      public ArrayList<Chofer> Listachoferes(Connection con) throws SQLException{

          ArrayList<Chofer> lista = new ArrayList<Chofer>();
      
  String sql = "select * from chofer";

        PreparedStatement ps = con.prepareStatement(sql);


          ResultSet rs = ps.executeQuery();
       while(rs.next()){
    Chofer bean = new Chofer();
        bean.setCod_chofer(rs.getInt(1)) ;
        bean.setCod_ruta(rs.getInt(2));
        bean.setNom_chofer(rs.getString(3));
        bean.setApe_chofer(rs.getString(4));
        bean.setTelefono(rs.getInt(5));
            bean.setSueldo(rs.getDouble(6));
         bean.setFnacimiento(rs.getString(7));
        bean.setFnacimiento(rs.getString(8));
         lista.add(bean);
        }
        return lista;


}











}
